namespace SimpleWebServices.Web.Mvc
{
    using System;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Routing;

    public sealed class GenericMvcHandler<T> : MvcHandler
        where T : ControllerBase
    {
        public GenericMvcHandler(RequestContext requestContext)
            : base(requestContext)
        {
        }

        protected override void ProcessRequest(HttpContextBase httpContext)
        {
            if (null == httpContext)
            {
                throw new ArgumentNullException("httpContext");
            }

            (Activator.CreateInstance<T>() as IController).Execute(this.RequestContext);
        }
    }
}